package com.fzz.learning_forum.dao;

import com.fzz.learning_forum.domain.Article;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

@Mapper
@Component
public interface ArticleMapping {

    //分页查询文章
    @Select("select * from tb_article")
    public List<Article> selectArticleWithPage();


    //根据id查询文章
    @Select("select * from tb_article where user_id=#{id}")
    public List<Article> selectArticleWithPageById(@Param("id") Integer id);

    //根据tags模糊查询文章
    @Select("<script> " +
            "select * from tb_article where 1=1" +
            "<if test='tags!=null'> and tags like concat('%',#{tags},'%')</if>" +
            "</script>")
    public List<Article> selectArticleByTags(@Param("tags") String tags);
}
